from django.db import models

# Create your models here.


class Tag(models.Model):
    name = models.CharField(verbose_name='标签', max_length=100)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name_plural = "标签"


class Domain_name(models.Model):
    status_choice = (
        (0, '激活'),
        (1, '停用')
    )
    domain = models.CharField(max_length=64, unique=True, verbose_name='域名地址')
    expiration = models.DateField(verbose_name='到期时间')
    status = models.SmallIntegerField(
        choices=status_choice, default=0, verbose_name='状态')
    tags = models.ManyToManyField(Tag, verbose_name='标签', blank=True)

    def __str__(self):
        return self.domain

    class Meta:
        ordering = ['-expiration']
        verbose_name_plural = "域名"
